/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky.support;

import java.util.HashSet;
import java.util.Set;
import ru.jSky.interfaces.Enchantment;
import ru.jSky.interfaces.FormList;

/**
 *
 * @author Rakev
 */
public class EnchantmentFormListRestrictionCollector {

    public Set<FormList> collect(Enchantment enchanment) {
        Set<FormList> collected = collectFromBaseEnchantment(enchanment);

        FormList restrictionFormList = enchanment.getWornRestrictionFormList();
        if (restrictionFormList != null) {
            collected.add(restrictionFormList);
        }

        return collected;
    }

    private Set<FormList> collectFromBaseEnchantment(Enchantment enchanment) {
        Enchantment base = enchanment.getBaseEnchantment();
        if (base != null) {
            return collect(base);
        } else {
            return new HashSet<>();
        }
    }
}
